
/**
 * 
 * 
 * 在字符串中查找字符 a
 * 
 * @param {*} source 
 * @returns 返回第一个匹配的位置
 */
function findA(source) {
    let findIndex = -1;
    if(source != null && source.length > 0) {
        for(let index in source) {
            let c = source.charAt(index);
            // console.log("index:" + index + " char:" + c);
            if(c == "a") {
                findIndex = index;
                break;
            }
        }
    }

    return findIndex;

}

let result1 = findA("abcd");
console.log(" result1:" + result1);
let result2 = findA("demoAa");
console.log(" result2:" + result2);
let result3 = findA("b");
console.log(" result3:" + result3);

